package com.mobi.cacti.rabbit.connectors;

import java.io.IOException;

import org.apache.http.HttpResponse;
import org.apache.http.client.ClientProtocolException;
import org.apache.http.client.HttpClient;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.entity.StringEntity;
import org.apache.http.protocol.HTTP;
import org.apache.http.util.EntityUtils;

import com.mobi.cacti.rabbit.response.Cache;

public class TicketListServerConnector extends AbstractServerConnector{

	private String loadingCurcitID;

	public void loadTicketRecentListForCurcit(String circuitID)
	{
		this.loadingCurcitID = circuitID;
		
		String url = "https://timonitorappuat.trueinternet.co.th/cactimobileservice/reqtfasticketlistrecenta.php";
		String xmlData =
				"<?xml version=\"1.0\" encoding=\"utf-8\"?> " +
				"<ReqTFASTicketListRecent>" +
				"<ReqSessionID>"+Cache.getRequestSessionID()+"</ReqSessionID>" +
				"<AppUser>COMi</AppUser> " +
				"<AppPass>b5d864cdeb699ebb3d17a6ff70c3aa5e</AppPass>" +
				"<CircuitID>"+circuitID+"</CircuitID> " +
				"</ReqTFASTicketListRecent>";

		this.execute(url,xmlData);

	}
	
	
	
	public void loadTicketHistoryListForCurcit(String circuitID)
	{
		this.loadingCurcitID = circuitID;
		
		String url = "https://timonitorappuat.trueinternet.co.th/cactimobileservice/reqtfasticketlisthistorya.php";
		String xmlData =
				"<?xml version=\"1.0\" encoding=\"utf-8\"?> " +
				"<ReqTFASTicketListHistory>" +
				"<ReqSessionID>"+Cache.getRequestSessionID()+"</ReqSessionID>" +
				"<AppUser>COMi</AppUser> " +
				"<AppPass>b5d864cdeb699ebb3d17a6ff70c3aa5e</AppPass>" +
				"<CircuitID>"+circuitID+"</CircuitID> " +
				"</ReqTFASTicketListHistory>";

		this.execute(url,xmlData);
	}
	
	@Override
	protected void onPostExecute(String result) {
		
		String[] resultArray = new String[]{loadingCurcitID,result};
		delegate.serverConnectorFinishBackgroundTask(this,resultArray);
	};


}
